<template>
  <form>
    <input type="text" v-model="user.username" />

    <input type="password" v-model="user.password" />

    <button type="submit" @click.prevent="login">登录</button>
  </form>
</template>
<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const user = ref({});
const login = () => {
  console.log(user.value);
  if (user.value.username == "admin" && user.value.password == "123456") {
    // 跳转到首页
    router.push({ path: "/" });
  } else {
    alert("登录失败");
  }
};
</script>
